<template>
	<view>
		<view class="header">
			<view class="header-icon">
				<image src="../../static/icon/back.png" style="width: 40rpx;height: 40rpx;" @click="back"></image>
			</view>
			<view class="header-title">企业列表</view>
		</view>
		<view style="background-color: rgb(245, 245, 245);padding: 10rpx;">
			<view class="cellBox" v-for="(item, index) in dataList" :key="item.id" @click="goEnterprise(item.id)">
				<view class="rotatBox">
					<view class="imgBox">
						<image :src="item.logoUrl" style="width: 100%; height: 100%"></image>
					</view>
					<view class="cardCss">
						<view class="cardTitle">{{ item.name }}</view>
						<view class="contentCss" v-html=" item.introduction" />
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mode: 'single',
				dataList: [],
				unitType: 2
			}
		},
		
		onLoad(options) {
			this.getTabList()
		},
		methods: {
			// 返回
			back() {
				const pages = getCurrentPages()
				if (pages && pages.length > 1) {
					uni.navigateBack({
						delta: 1
					})
				} else {
					history.go(-1)
				}
			},
			// 企业跳转
			goEnterprise(id) {
				uni.navigateTo({
					url: '/pages/index/enterprise?id=' + id
				})
			},
			//渲染企业的数据
			getTabList() {
				const that = this
				const introductionsList = []
				that.$api.request('advert', 'company', {
					unitType: that.unitType
				}).then(res => {
					that.dataList = res.data.items
					for (let i = 0; i < that.dataList.length; i++) {
						//富文本图片隐藏
						that.dataList[i].introduction = that.dataList[i].introduction.replace(/\<img/gi,
							'<img style="display:none;" ');
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.header{
		display: flex;
		height: 160rpx;
		line-height: 160rpx;
		.header-icon{
			padding-left: 40rpx;
			padding-top: 10rpx;
			flex: 3;
		}
		.header-title{
			flex: 5;
		}
	}
	.cellBox {
		background-color: white;
		margin: 20rpx;
	}

	.rotatBox {
		position: relative;
		display: flex;
		flex-direction: row;
		padding: 13px 16px;
		padding-left: 16px;
		flex: 1;
		overflow: hidden;

		.imgBox {
			flex-shrink: 0;
			margin-right: 11px;
			width: 125px;
			height: 75px;
			border-radius: 6px;
			overflow: hidden;
			border: 1px #f5f5f5 solid;
		}
	}

	.cardCss {
		padding-right: 8px;
		flex: 1;
		color: #3b4144;
		justify-content: space-between;
		overflow: hidden;

		.cardTitle {
			font-size: 15px;
			color: #3b4144;
			overflow: hidden;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
		}


		.contentCss {
			font-size: 24rpx;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
			color: #999;
			font-size: 13px;
			overflow: hidden;
			margin-top: 10rpx;
			line-height: 46rpx
		}

		//只能H5显示
		::v-deep img {
			width: 100%;
		}
	}
</style>
